package com.thghh.task;

import java.util.concurrent.Callable;
import java.util.function.Predicate;

/**
 * TODO
 *
 * @author pengzhikang
 * @date 2022/11/4 16:41
 * @since 1.0.0
 */
public class StopCallable implements Callable<Void> {

    private Thread currentThread;

    private Predicate<Object> predicate;

    // public StopCallable(Predicate<Object> predicate) {
    //     this.predicate = predicate;
    // }

    public StopCallable() {
        this.currentThread = Thread.currentThread();
    }

    @Override
    public Void call() throws Exception {
        while (true) {
            System.out.println("执行中...");
            // 用于取消时，可被中断。(sleep遇到中断标志会抛出InterruptedException异常。从而结束方法）
            if (Thread.interrupted()) {
                break;
            }
        }
        return null;
    }
}
